package com.pt25.study.example.domain.sharding.service.impl;

import com.pt25.study.example.domain.sharding.ddo.ShardingSd;
import com.pt25.study.example.domain.sharding.factory.ShardingFactory;
import com.pt25.study.example.domain.sharding.service.ShardingSdService;
import com.pt25.study.example.repository.sharding.persistence.ShardingSdRepo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class ShardingSdServiceImpl implements ShardingSdService {

    @Resource
    private ShardingFactory shardingFactory;

    @Resource
    private ShardingSdRepo shardingSdRepo;

    @Override
    public ShardingSd getShardingSd(Long id) {
        return shardingSdRepo.getShardingSd(id);
    }

    @Override
    public void addShardingSd(ShardingSd shardingSd) {
        shardingSdRepo.save(shardingFactory.ShardingSD2ShardingSDPO(shardingSd));
    }
}
